package asteroids.model.programs.statements.ProgramStatements;

import asteroids.model.programs.expressions.Expression;
import asteroids.model.programs.statements.Statement;

/**
 * A class representing a PrintStatement, this class is a sub-class of the
 * Statement-class.
 * 
 * A Print-statement will print out it's expression to the console.
 * 
 * @author Michiel De Cuyper
 * @version 09.05
 * 
 */
public class PrintStatement extends Statement {

	/**
	 * Constructor for the PrintStatement-class
	 * 
	 * @param line
	 *            The line on which this if-statement is found
	 *            Gets passed to the Statement-class
	 * @param column
	 *            The column in which this if-statement is found
	 *            Gets passed to the Statement-class
	 * @param expression
	 *            The expression that will be printed to the screen
	 */
	public PrintStatement(int line, int column, Expression exp) {
		super(line, column);
		this.text = exp;
	}

	/**
	 * Executes this PrintStatement, by printing out it's expression to the
	 * console.
	 * 
	 * @effect ...
	 *         | System.out.println(this.getExpression().toString())
	 */
	@Override
	public void execute() {
		System.out.println(text.getResult().toString());
	}

	/**
	 * Returns the expression of this PrintStatement
	 * 
	 * @return ...
	 *         | return this.expression
	 */
	public Expression getExpression() {
		return this.text;
	}

	private Expression text;

	@Override
	public String typeCheckStatement(String errorMessage) {
		return null;
	}
}
